package com.example.armmvvm.ui.customdraw.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.PointF
import android.util.AttributeSet
import com.example.arm.ext.dp
import timber.log.Timber

/**
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.example.armmvvm.ui.customdraw.view
 * @createTime 创建时间 ：2022/2/21
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class PointFTypeEvaluatorView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : BaseCustomView(context, attrs, defStyleAttr) {

    var point: PointF = PointF(0f, 0f)
        set(value) {
            field = value
            invalidate()
        }

    var countText: Int = 0
        set(value) {
            field = value
//            Timber.d(value.toString())
            invalidate()
        }

    init {
        paint.strokeWidth = 10.dp
        paint.color = Color.BLUE
        paint.textSize = 16.dp
        paint.textAlign = Paint.Align.CENTER
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        canvas?.drawPoint(point.x, point.y, paint)
        canvas?.drawText(countText.toString(), width / 2f, height / 2f, paint)
    }
}